<div id="container">
<p id="description"></p>
</div>
<div id="console"></div>
<script src="../../resources/js-test.js"></script>
<script>
description('Insert newline into dynamically created textarea');
function $(id) { return document.getElementById(id); }
function visibleNewline(s) { return s.replace(/\n/g, '/'); }

var sampleText = 'hello\n\nworld';
var textarea = document.createElement('textarea');
textarea.rows = 5;
textarea.value = '\n';
$('container').appendChild(textarea);
textarea.select();
textarea.focus();
document.execCommand('Delete', false);
document.execCommand('InsertHtml', false, sampleText);
shouldBeEqualToString('visibleNewline(textarea.value)', visibleNewline(sampleText));

if (window.testRunner)
    $('container').outerHTML = '';
</script>
